﻿using Dyao.Book.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Dyao.Book.Repository
{
    public class BookEntityTypeConfiguration : IEntityTypeConfiguration<BookEntity>
    {
        public void Configure(EntityTypeBuilder<BookEntity> builder)
        {
            builder.Property(a => a.Completed).HasBoolToStringConversion();
            builder.Property(a => a.SourceType).HasEnumToStringConversion();
            builder.Property(a => a.IsDel).HasBoolToStringConversion();
            builder.Property(a => a.IsMatchSource).HasBoolToStringConversion();

            builder.HasQueryFilter(b => b.IsDel == false);
        }
    }
}
